﻿using MyCourseManageProject.Dal.Service;
using MyCourseManageProject.Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace MyCourseManageProject.Bll
{

    public class CoursesBll
    {
        CoursesDal cdal = new CoursesDal();
        public bool AddCourses(Courses cs, out string msg)
        {


            int row = cdal.AddCourses(cs);
            if (row > 0)
            {
            msg="恭喜课程添加成功!";
                return true;
            }
            else
            {
            msg="课程课程添加失败!";
                return false;
            }

        }
        //查询对个对象方法
        public List<Courses> GetAll(int categoryId, string courseName)
        {
            return cdal.GetAll(categoryId, courseName);
        
        }
        public bool UpdateCourses(Courses cs,out string msg)
        {

            int row = cdal.UpdateCourses(cs);
            if (row > 0)
            {
                msg = "恭喜课程修改成功!";
                return true;
            }
            else
            {
                msg = "课程修改失败!";
                return false;
            }
        }

        public bool DelectCourses(Courses cs, out string msg)
        {
            int row = cdal.DelectCourses(cs);
            if (row > 0)
            {
                msg = "课程删除成功!";
                return true;
            }
            else
            {
                msg = "课程删除失败!";
                return false;
            }
        }
    }
}
